package com.dgut.service.background.service;

import com.dgut.service.background.dao.OutsDao;
import com.dgut.service.background.entity.Outs;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

@Service
public class OutsService {
    @Autowired
    private OutsDao outsDao;

    public Page<Outs> findAllOuts(int page){
        Pageable pageable = PageRequest.of(page, 10);
        Page<Outs> gos = outsDao.findAll(pageable);
        return gos;
    }
    public Page<Outs> findAllOuts(Pageable pageable){
        return outsDao.findAll(pageable);
    }

    public Page<Outs> findByDate(String date1, String date2, Pageable pageable){
        return outsDao.findAllByTimesBetween(date1,date2,pageable);
    }

    public Page<Outs> findAllByTimesBetweenAndUsernameLike(String username, String[] towDate, Pageable pageable){
        return outsDao.findAllByTimesBetweenAndUsernameLike(towDate[0], towDate[1], username, pageable);
    }

    public Page<Outs> findAllByUsername(String username, Pageable pageable){
        return outsDao.findAllByUsername(username, pageable);
    }

}
